package conf

import (
	"github.com/spf13/cast"
	"svvenus/util/uttype"
)

var (
	ListNameSur    = make([]string, 0)
	ListNameMale   = make([]string, 0)
	ListNameFemale = make([]string, 0)
	ListNameBad    = make([]string, 0)

	V玩家邮件最大数量   = 0
	V玩家未读邮件有效时间 = 0
	V玩家已读邮件有效时间 = 0

	V玩家最大体力       int64 = 0
	V玩家体力回复每次     int64 = 0
	V玩家体力多少分钟回复一次 int64 = 0
)

func InitExtGame() bool {

	ConfigLock.Lock()
	defer ConfigLock.Unlock()

	ListNameSur = make([]string, 0)
	for _, v := range MapNameSur {
		ListNameSur = append(ListNameSur, v.LangChs)
	}
	ListNameMale = make([]string, 0)
	for _, v := range MapNameMale {
		ListNameMale = append(ListNameMale, v.LangChs)
	}
	ListNameFemale = make([]string, 0)
	for _, v := range MapNameFemale {
		ListNameFemale = append(ListNameFemale, v.LangChs)
	}
	ListNameBad = make([]string, 0)
	for _, v := range MapNameBad {
		ListNameBad = append(ListNameBad, v.LangChs)
	}

	V玩家邮件最大数量 = GlobalGetInt(EGlobalId玩家邮件最大数量)
	V玩家未读邮件有效时间 = GlobalGetInt(EGlobalId玩家未读邮件有效时间)
	V玩家已读邮件有效时间 = GlobalGetInt(EGlobalId玩家已读邮件有效时间)

	V玩家最大体力 = GlobalGetInt64(EGlobalId玩家最大体力)
	V玩家体力回复每次 = GlobalGetInt64(EGlobalId玩家体力回复每次)
	V玩家体力多少分钟回复一次 = GlobalGetInt64(EGlobalId玩家体力多少分钟回复一次)

	return true
}

func GlobalGetString(id int) string {
	cfg, ok := MapGlobal[id]
	if ok {
		return cfg.Value
	}
	return ""
}
func GlobalGetInt(id int) int {
	return cast.ToInt(GlobalGetString(id))
}
func GlobalGetInt32(id int) int32 {
	return cast.ToInt32(GlobalGetString(id))
}
func GlobalGetInt64(id int) int64 {
	return cast.ToInt64(GlobalGetString(id))
}
func GlobalGetListInt(id int) []int {
	return uttype.StringToListInt(GlobalGetString(id))
}
func GlobalGetListListInt(id int) [][]int {
	return uttype.StringToListListInt(GlobalGetString(id))
}
func GlobalGetListListInt64(id int) [][]int64 {
	return uttype.StringToListListInt64(GlobalGetString(id))
}
